#[macro_use] extern crate honggfuzz;
 
extern crate string_interner;

use string_interner::{DefaultStringInterner, Sym};

fn clone_and_drop() -> (DefaultStringInterner, Sym) {
    let mut old = DefaultStringInterner::new();
    let foo = old.get_or_intern("foo");

    let new = old.clone();
    let _bar = old.get_or_intern("bar");

    (new, foo)
}

fn boom() {
    let (mut new, foo) = clone_and_drop();
    assert_eq!(
        new.get_or_intern("foo"),
        foo,
        "`foo` should represent the string \"foo\" so they should be equal"
    );
    println!("be equal!");
}


fn main() {
    loop {
        fuzz!(|data: &[u8]| {
            if data.len() != 6 {return}
            if data[0] != b'q' {return}
            if data[1] != b'w' {return}
            if data[2] != b'e' {return}
            if data[3] != b'r' {return}
            if data[4] != b't' {return}
            if data[5] != b'y' {return}
            boom();
        });
    }
}